/**
 * 
 */
package com.gosophia.conferenceManagement.common.ws.test.integrate;

import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
import org.junit.After;
import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.transaction.annotation.Transactional;

import com.gosophia.commons.exception.BusinessException;
import com.gosophia.userManagement.entity.UserInfo;
import com.gosophia.userManagement.service.UserManagementService;

/**
 * 功能：      
 * @author zhangdongsheng
 * @since  2011-3-23
 *  Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@ContextConfiguration(locations = { "classpath*:moduleContext.xml",
"classpath:applicationContext-test.xml" })
@Transactional(rollbackFor = { BusinessException.class })
public class ConferenceJbpmProcessTestBase extends AbstractTransactionalJUnit4SpringContextTests {
    private ProcessDefinition processDefinition;
    private JbpmContext jbpmContext;
    @Autowired
    private UserManagementService userManagementService;
    protected   UserInfo oneOperator   ;
    protected   UserInfo twoOperator   ;
    @Autowired
    private JbpmConfiguration jbpmConfiguration;
  
    @Before
    public  void loadingAndDeployProcessingDefiniation(){
         oneOperator = userManagementService.findUserInfoByUserInfoId(1000L) ;
        twoOperator = userManagementService.findUserInfoByUserInfoId(1001L) ;
        processDefinition =new ProcessDefinition().parseXmlResource("conference/processdefinition.xml");
        jbpmContext=jbpmConfiguration.createJbpmContext();
        jbpmContext.deployProcessDefinition(processDefinition);
        processDefinition =jbpmContext.getGraphSession().findLatestProcessDefinition("hygl");
       // processInstance =processDefinition.createProcessInstance();
    }
    
//    @Test
//    public void testConferenceProcessStarting(){
//        //加载流程图
//        //测试singal 
//       // 测试创建job
//        setProcessVariable("conferenceModel",ConferenceConstants.NO_APPLICATION_CONFERENCE);//无需申请
//        setProcessVariable("conferenceType",ConferenceConstants.MIDDLE_TYPE_CONFERENCE);//发起小型会议
//        for (int i = 0; i < 20; i++) {
//            processInstance.signal();
//        }
// 
//   }
//    
//    private void setProcessVariable(String key, String value){
//        processInstance.getContextInstance().setVariable(key, value);
//    }
//    
//    @Test
//    public void testNodeActionHandler(){
//      ProcessDefinition conferenceProcessDef =   jbpmContext.getGraphSession().findLatestProcessDefinition("huiyi");
//      List<Node> allNodes = conferenceProcessDef.getNodes();
//      for (Node node : allNodes) {
//        logger.debug("输出所有节点的名称："+node.getName());
//    }  
//        
//    }
    
    @After
    public void tearDown(){
        //jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition);
        jbpmContext.close();
    }

 
 
}
